#include <iostream>
using namespace std;

/* 请在这里填写答案 */
long long gcd(long long a, long long b)
{
    if (b == 0)
    {
        return a;
    }
    return gcd(b, a % b);
}

class Fraction
{
private:
    long long z, m;

public:
    Fraction()
    {
        z = 1;
        m = 1;
    }
    Fraction(double x) : z(x) { m = 1; }
    Fraction(double x, double y)
    {
        int g = gcd(x, y);
        z = x / g;
        m = y / g;
    }
    Fraction(long long x, double y)
    {
        long long g = gcd(x, y);
        z = x / g;
        m = y / g;
    }
    Fraction(const Fraction &f) : z(f.z), m(f.m) {}
    
    Fraction& operator=(const double d)
    {
        int t = 1;
        double d_ = d;
        while (d_ - static_cast<int>(d_) != 0 && t <= 1000000) {
            d_ *= 10;
            t *= 10;
        }
        int g = gcd(d_, t);
        z = d_ / g;
        m = t / g;
        return *this;
    }

    Fraction operator+(const Fraction &f1)
    {
        Fraction f(z * f1.m + f1.z * m, m * f1.m);
        return f;
    }
    Fraction operator-(const Fraction &f1)
    {
        Fraction f(z * f1.m - f1.z * m, m * f1.m);
        return f;
    }

    Fraction operator*(const Fraction &f1)
    {
        Fraction f(z * f1.z, m * f1.m);
        return f;
    }

    Fraction operator/(const Fraction &f1)
    {
        Fraction f(z * f1.m, m * f1.z);
        return f;
    }

    operator double() const
    {
        double t = z/m;
        return 1.0 * z/m;
    }

    friend istream &operator>>(istream &in, Fraction &f)
    {
        string str;
        in >> str;
        f.z = stod(str.substr(0, str.find("/")));
        f.m = stod(str.substr(str.find("/") + 1));
        return in;
    }

    friend ostream &operator<<(ostream &out, const Fraction &f)
    {
        if (f.m != 1)
            out << f.z << "/" << f.m;
        else
            out << f.z;
        return out;
    }
};

int main(void)
{
    Fraction f1;
    Fraction f2;
    cin >> f1 >> f2;
    cout << f1 + f2 << endl;
    cout << (double)(f1 + f2) << endl;
    cout << f1 - f2 << endl;
    cout << f1 * f2 << endl;
    cout << f2 / f1 << endl;
    double d;
    cin >> d;
    Fraction f((long long)(d * 1e16), 1e16);
    cout << f << endl;
    f = 0.5;
    cout << f << endl;
    Fraction *p = &f1;
    f1 = *p;
    cout << f1 << endl;
    cin >> f1;
    f1 = f1 * Fraction(2.0);
    cout << f1 << endl;
}
